<?php
namespace app\middleware;

use think\facade\Db;
use think\facade\Session;
use think\facade\Config;
use think\facade\Request;
use common\Token;
class TokenCheck
{

    public function handle($request, \Closure $next)
    {
        $token = input("token", 0, 'trim');
        $token = $token ? $token : Request::header('token');
        if (!$token) return json(['msg' => '非法请求！', 'code' => 9999]);

        $result = Token::verifyToken($token);
        if (!$result) return json(['msg' => '非法请求！', 'code' => 9999]);

        $request->tokenInfo = $result;
        return $next($request);
    }
	
}